<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Http\Resources\CourseResourceCollection;
use App\Http\Resources\SwiperResourceCollection;
use App\Models\Courses as CourseModel;
use Illuminate\Http\Request;
use App\Models\Swipers as SwiperModel;

class Swipers extends Controller
{

    public function getSwipers(Request $request)
    {
        $swipers = SwiperModel::orderBy('sort','desc')->get();
        $datas = new SwiperResourceCollection($swipers);
        return response()->json(['status'=>200,'msg'=>'请求成功','datas'=>$datas]);
    }

    public function getAllCourse(Request $request)
    {
        $swipers = SwiperModel::orderBy('sort','desc')->get();
        $datas = new SwiperResourceCollection($swipers);
        $courses = CourseModel::orderBy('id','desc')->get();
        return response()->json(['status'=>200,'data'=>['swipers'=>$datas,'courses'=>new CourseResourceCollection($courses)],'msg'=>'请求成功']);
    }



}
